import connect
client = connect.connect()

# 使用数据库test
db = client['test']

# 获取对应的集合（列表）
collection = db.test

# 展示列表的所有内容
def showCollectionData(c):
    result = c.find()
    for item in result:
        print(item)

# 单个插入
# insert_data = {
#     "key": "123",
#     "age": 18,
#     "name": "john"
# }
# collection.insert_one(insert_data)
# showCollectionData(collection)

# 批量插入

insert_data = [
    {
        "key": "123",
        "age": 18,
        "name": "john"
    },
    {
        "key": "456",
        "age": 20,
        "name": "lucy"
    },
    {
        "key": "789",
        "age": 22,
        "name": "mike"
    },
]
collection.insert_many(insert_data)
showCollectionData(collection)